package com.ling.luo.redis;

import com.ling.luo.user.entity.User;
import com.ling.luo.util.RedisUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @program: springbootdemo
 * @Date: 2019/2/22 15:03
 * @Author: zjjlive
 * @Description:
 */
@RequestMapping("/redis")
@RestController
public class RedisController {

    /**
     * redis中存储的过期时间60s
     */
    private static int ExpireTime = 60;

    @Resource
    private RedisUtils redisUtil;

    @PostMapping("/set")
    public boolean redisset(String key, String value){
        User userEntity =new User();
        userEntity.setId(1);
        userEntity.setName("zhangsan");
        userEntity.setAge(22);
        return redisUtil.set(key,value);
    }

    @GetMapping("/get")
    public Object redisget(String key){
        return redisUtil.get(key);
    }

    @PutMapping("expire")
    public boolean expire(String key){
        return redisUtil.expire(key,ExpireTime);
    }
}

